<template>
  <div class="returnConfirmCheck">
    <el-breadcrumb separator="/" style="font-size:16px;height:30px;">
      <el-breadcrumb-item :to="{ path: '/returnConfirm' }">回款确认</el-breadcrumb-item>
      <el-breadcrumb-item v-if="checkOrEdit == 1 ">查看</el-breadcrumb-item>
      <el-breadcrumb-item v-if="checkOrEdit == 2 ">编辑</el-breadcrumb-item>
      <el-breadcrumb-item v-if="checkOrEdit == 3 ">审核</el-breadcrumb-item>
    </el-breadcrumb>
    <!-- 编辑 -->
    <div v-show="edit == 1">
      <div class="top" v-if='checkOrEdit == 1 || checkOrEdit == 3'>
        <span class="one">
          <span>本次回款总金额：</span>
          <span>{{brokerageTotal}}元</span>
        </span>
      </div>
      <el-table :data="listData" border style="width: 100%" ref="multipleTable" @selection-change="handleSelectionChange">
        <el-table-column align="center" fixed width="55" type="selection" v-if="checkOrEdit == 2"></el-table-column>
        <el-table-column align="center" fixed  label="序号" type="index" width="60"></el-table-column>
        <el-table-column align="center" prop="cityName" label="城市" width="150"></el-table-column>
        <el-table-column align="center" prop="customerName" label="客户姓名" width="150"></el-table-column>
        <el-table-column align="center" prop="customerPhone" label="手机号" width="150" :formatter="initPhone"></el-table-column>
        <el-table-column align="center" prop="devName" label="楼盘名称" width="300"></el-table-column>
        <el-table-column align="center" prop="houseNum" label="房源" width="200"></el-table-column>
        <el-table-column align="center" prop="amountTotalToBePay" label="应回款金额" width="120" :formatter="initMoney"></el-table-column>
        <el-table-column align="center" prop="afterAmountTotal" label="后佣回款" width="120" :formatter="initMoney"> </el-table-column>
        <el-table-column align="center" prop="awardAmountTotal" label="经纪人奖励" width="150" :formatter="initMoney"></el-table-column>
        <el-table-column align="center" prop="auditTime" label="佣金结算审核通过时间" width="180" :formatter="initTime"></el-table-column>
        <el-table-column align="center" prop="surplusAmount" label="待回款金额" width="180" :formatter="initMoney"></el-table-column>
        <el-table-column align="center" prop="amountRecieved" label="本次回款金额" width="180" :formatter="initMoney"></el-table-column>
        <el-table-column align="center" fixed="right" label="操作" width="80" v-if="checkOrEdit == 2">
          <template slot-scope="scope">
            <el-button  type="text" size="small" @click="adjustment(scope.row.index)">调整</el-button>
          </template>
        </el-table-column>
      </el-table>
      <el-dialog
        title="调整回款金额"
        :visible.sync="dialogVisible"
        width="450px"
        :before-close="handleClose">
        <p>
          <span>应回款金额：</span>
          <span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{{dialogVisible? (listData[index].amountTotalToBePay):'' | moneyFilter}}元</span>
        </p>
        <p>
          <span>待回款金额：</span>
          <span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{{dialogVisible? listData[index].surplusAmount:'' | moneyFilter}}元</span>
        </p>
        <el-form :inline="true" class="demo-form-inline">
          <el-form-item label="本次回款金额：">
            <el-input v-model="listData[index].amountRecieved" placeholder="" @input="handleBlur" size="mini" v-if="dialogVisible" style="width:80%"></el-input>
            <span>元</span>
          </el-form-item>
        </el-form>
        <span slot="footer" class="dialog-footer">
          <el-button @click="cancle">取 消</el-button>
          <el-button type="primary" @click="confirm(listData[index].amountRecieved)">确 定</el-button>
        </span>
      </el-dialog>
      <div class="part">
        <div class="txt">回款确认单：</div>
        <div class="content">
          <upload :multiple="true" ref="upload1" :fileList="returnConfirmList"  v-if="checkOrEdit == 2"/>
          <upload :multiple="true" ref="upload1" :fileList="returnConfirmList"  v-else readonly/>
        </div>
      </div>
      <div class="step" v-if="checkOrEdit == 1">
        <el-steps :space="300" :active="activeNum" finish-status="success">
          <el-step title="运营提交审核"></el-step>
          <el-step title="财务审核"></el-step>
        </el-steps>
      </div>
      <div class="btn" v-if="checkOrEdit == 2">
        <el-button type="primary" size="mini" @click="handleAdd">继续添加</el-button>
        <el-button type="primary" size="mini" @click="handleSave(0)">保存</el-button>
        <el-button type="primary" size="mini" @click="handleSave(1)">保存并提交审核</el-button>
      </div>
      <div class="part" v-show="checkOrEdit != 3">
        <div class="txt" v-show="checkOrEdit == 1">审核记录：</div>
        <div class="txt" v-show="checkOrEdit == 2">操作记录：</div>
        <div class="content">
          <el-table :data="recordList" border style="width: 781px">
            <el-table-column align="center" prop="auditStatusNote" label="操作" width="150"></el-table-column>
            <el-table-column align="center" prop="submitPersonName" label="操作人" width="150"></el-table-column>
            <el-table-column align="center" prop="roleTypeNote" label="角色" width="150"></el-table-column>
            <el-table-column align="center" prop="createTime" label="时间" width="180"></el-table-column>
            <el-table-column align="center" prop="remark" label="理由" width="150"></el-table-column>
          </el-table>
        </div>
      </div>
      <div class="part" v-show="checkOrEdit == 3">
        <div class="txt">审核理由：</div>
        <div>
          <textarea name="" id="" cols="100" rows="10" v-model="reason"></textarea>
        </div>
      </div>
      <div class="btn" v-if="checkOrEdit == 3">
        <el-button type="primary" size="mini" @click="handleReject(0)">通过</el-button>
        <el-button type="primary" size="mini" @click="handleReject(1)">拒绝</el-button>
      </div>
    </div>
    <!-- 继续添加 -->
    <div v-show="edit == 0">
      <div class="filter">
        <el-form :inline="true" class="demo-form-inline">
          <el-form-item label="城市：">
            <el-select v-model="cityId" placeholder="请选择城市" size="mini" filterable clearable @change="getCityId">
              <el-option :label="item.city" :value="item.cityId" v-for="(item,idx) in cityList" :key="idx"></el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="楼盘：">
            <el-select v-model="devId" placeholder="请选择楼盘" size="mini" filterable clearable>
              <el-option :label="item.devName" :value="item.devId" v-for="(item,idx) in devList" :key="idx"></el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="客户姓名：">
            <el-input v-model="customerName" placeholder="请输入客户姓名" size="mini"></el-input>
          </el-form-item>
          <el-form-item style="margin-top:-2px;margin-left:10px;">
            <el-button type="primary" @click="checkList" size="mini" id="monitorEnter">查询</el-button>
          </el-form-item>
        </el-form>
      </div>
      <el-table :data="listDataNew" border style="width: 100%" @selection-change="handleSelectionChangeNew">
        <el-table-column align="center" fixed type="selection" width="55"></el-table-column>
        <el-table-column align="center" fixed  label="序号" type="index" width="60"></el-table-column>
        <el-table-column align="center" prop="cityName" label="城市" width="150"></el-table-column>
        <el-table-column align="center" prop="customerName" label="客户姓名" width="150"></el-table-column>
        <el-table-column align="center" prop="customerPhone" label="手机号" width="150" :formatter="initPhone"></el-table-column>
        <el-table-column align="center" prop="houseNum" label="房源" width="200"></el-table-column>
        <el-table-column align="center" prop="devName" label="楼盘名称" width="300"></el-table-column>
        <el-table-column align="center" prop="amountTotalToBePay" label="应回款金额" width="120" :formatter="initMoney"></el-table-column>
        <el-table-column align="center" prop="afterAmountTotal" label="后佣回款" width="120" :formatter="initMoney"> </el-table-column>
        <el-table-column align="center" prop="awardAmountTotal" label="经纪人奖励" width="150" :formatter="initMoney"></el-table-column>
        <el-table-column align="center" prop="auditTime" label="佣金结算审核时间" width="180" :formatter="initTime"></el-table-column>
        <el-table-column align="center" prop="surplusAmount" label="待回款金额" width="180" :formatter="initMoney"></el-table-column>
        <el-table-column align="center" prop="amountRecieved" label="本次回款金额" width="180" :formatter="initMoney"></el-table-column>
      </el-table>
      <div class="block">
        <el-pagination
          background
          @size-change="handleSizeChangeNew"
          @current-change="handleCurrentChangeNew"
          :current-page.sync="pageDataNew.pageNum"
          :page-sizes="[10, 20, 30, 40]"
          :page-size="pageDataNew.pageSize"
          layout="total, sizes, prev, pager, next"
          :total="totalSizeNew">
        </el-pagination>
      </div>
      <div style="text-align:center;margin-top:40px;margin-bottom:30px;">
        <el-button type="primary" @click="handleAddBatch(1)" size="mini">添加到批次</el-button>
        <el-button type="primary" @click="handleAddBatch(2)" size="mini">添加到批次到下一步</el-button>
      </div>
    </div>
  </div>
</template>

<script>
import api from "@/api/apiPath"
import util from '@/common/utils'
import upload from '@/components/common/Upload'
export default {
  name:"returnConfirmCheck",
  components: {
    upload
  },
  data() {
    return {
      cityList:[],
      cityId:'',
      devList:[],
      devId:'',
      edit:1,
      activeNum:undefined,
      reason:'',
      dialogVisible:false,
      brokerageTotal:0,
      listData: [],
      listDataNew:[],
      tiaozhengListData: [],
      recordList:[],
      returnConfirmList:[],
      multipleSelection:[],
      multipleSelectionAllAdd:[],
      multipleSelectionEditAdd:[],
      tempcompanyInfoIdReturnAdd:[],
      idKeyNew:'companyInfoId',
      checkOrEdit:window.sessionStorage.getItem('returnConfirmCheckOrEdit'),
      totalSize:0,
      totalSizeNew:0,
      pageData:{
        pageNum:1,
        pageSize:10
      },
      pageDataNew:{
        pageNum:1,
        pageSize:10
      },
      returnConfirmData:{
        pdfarr:[],
        pictures:[],
      },
      index:undefined,
      id:[],
      customerName:''
    }
  },
  filters:{
    moneyFilter(val){
      return util.formatMoney(val)
    }
  },
  mounted() {},
  created() {
    window.localStorage.removeItem('tempcompanyInfoIdReturnAdd')
    this.getCityList()
    this.getDevList()
    this.getActiveNum()
    if(window.sessionStorage.getItem('returnConfirmCheckOrEdit') == 1 || window.sessionStorage.getItem('returnConfirmCheckOrEdit') == 3){
      this.getOrderList()
    }else if(window.sessionStorage.getItem('returnConfirmCheckOrEdit') == 2){
      this.getEditOrderList()
    }
    this.getRemarkList()
    setTimeout(()=>{
      this.orderList(this.id)
    },300)
  },
  methods: {
    checkList(){
      if(window.localStorage.getItem("tempcompanyInfoIdReturnAdd")){
        this.id = window.localStorage.getItem("tempcompanyInfoIdReturnAdd").split(",")
      }
      this.pageDataNew.pageNum = 1
      this.orderList(this.id)
    },
    // 订单总列表
    orderList(tempcompanyInfoId){
      console.log(tempcompanyInfoId);
      let temId = [];
      if (tempcompanyInfoId == []) {
        temId = [];
      } else {
        temId = tempcompanyInfoId
      }
      this.axios.post(api.getBrokerageCompanyInfoReturnConfirmList,{
        pageNum:this.pageDataNew.pageNum,
        pageSize:this.pageDataNew.pageSize,
        devId:this.devId,
        cityId:this.cityId,
        tempcompanyInfoId:temId,
        customerName:this.customerName
      }).then(res=>{
        if(res.data.code == 200){
          this.totalSizeNew = res.data.data.total
          this.listDataNew = res.data.data.rows
          this.listDataNew.forEach((item,index)=>{
            item.index = index
          })
        }
      })
    },
    // 添加到批次
    handleAddBatch(val){
      let multipleSelection = this.multipleSelection.length
      this.multipleSelection = this.multipleSelection.concat(this.multipleSelectionEditAdd)
      if (window.localStorage.getItem("tempcompanyInfoIdReturnAdd")) {
        let tempcompanyInfoIdReturnAdd = window.localStorage
          .getItem("tempcompanyInfoIdReturnAdd")
          .split(",")
        window.localStorage.setItem(
          "tempcompanyInfoIdReturnAdd",
          tempcompanyInfoIdReturnAdd.concat(this.tempcompanyInfoIdReturnAdd)
        )
      } else {
        window.localStorage.setItem(
          "tempcompanyInfoIdReturnAdd",
          this.tempcompanyInfoIdReturnAdd
        )
      }
      if(val == 1){
        if(this.tempcompanyInfoIdReturnAdd.length == 0){
          this.$message({
            type: "warning",
            message: "至少选择一条订单并添加到批次"
          })
          return
        }
        // 被选中的楼盘id
        let devId = []
        this.multipleSelection.forEach(item=>{
          devId.push(item.devId)
        })
        if(Array.from(new Set(devId)).length!=1){
          this.$message.error('请选择同一楼盘的订单')
          this.multipleSelection = this.multipleSelection.splice(0,multipleSelection)
          console.log(this.multipleSelection)
          return
        }
        this.listData = this.multipleSelection
        this.listData.forEach((item,index)=>{
          item.index = index
        })
        let list = JSON.stringify(this.listData)
        this.tiaozhengListData = JSON.parse(list)
        this.id = window.localStorage.getItem("tempcompanyInfoIdReturnAdd").split(",")
        this.orderList(this.id)
        this.$message({
          type:'success',
          message:'成功添加'+this.tempcompanyInfoIdReturnAdd.length+'条信息到批次'
        })
      }else if (val == 2){
        console.log(3);
        console.log(this.tempcompanyInfoIdReturnAdd);
        console.log(this.multipleSelection);

        if(this.tempcompanyInfoIdReturnAdd.length == 0 ){
          if(this.multipleSelection.length == 0){
            this.$message({
              type: "warning",
              message: "至少选择一条订单并添加到批次"
            })
            return
          }
          this.edit = 1
        }else{
          // 被选中的楼盘id
          let devId = []
          console.log(this.multipleSelection);

          this.multipleSelection.forEach(item=>{
            devId.push(item.devId)
          })
          if(Array.from(new Set(devId)).length!=1){
            this.$message.error('请选择同一楼盘的订单')
            this.multipleSelection = this.multipleSelection.splice(0,multipleSelection)
            return
          }
          this.listData = this.multipleSelection
          this.listData.forEach((item,index)=>{
            item.index = index
          })
          let list = JSON.stringify(this.listData)
          this.tiaozhengListData = JSON.parse(list)
          this.edit = 1
          this.id = window.localStorage.getItem("tempcompanyInfoIdReturnAdd").split(",");
          this.orderList(this.id)
          this.$message({
            type:'success',
            message:'成功添加'+this.tempcompanyInfoIdReturnAdd.length+'条信息到批次'
          })
        }
        // this.devInfo = this.multipleSelection[0];
        // this.newBatch = !this.newBatch;
      }
      this.toggleSelection(this.multipleSelection)
    },
    // 城市列表
    getCityList(){
      this.axios.post(api.CITYLIST).then(res=>{
        if(res.data.code == 200){
          this.cityList = res.data.data.cityList
        }
      })
    },
    getCityId(val){
      this.getDevList(val)
      this.devId = ''
    },
    // 楼盘列表
    getDevList(val){
      this.axios.post(api.queryAllDevList,{
        cityId:val
      }).then(res=>{
        if(res.data.code == 200){
          this.devList = res.data.data
        }
      })
    },
    jiaoyan(val,confirm){
      if(!isNaN(val)){
        if(val>this.listData[this.index].surplusAmount){
          this.$message({
            type:'warning',
            message:'本次回款金额不能大于待回款金额'
          })
          return
        }
        if(confirm == 1){
          this.dialogVisible = false
          let list = JSON.stringify(this.listData)
          this.tiaozhengListData = JSON.parse(list)
        }
      }else{
        this.$message({
          type:'warning',
          message:'只能输入数字'
        })
        return
      }},
    // 校验调整本次回款金额
    handleBlur(val){
      this.jiaoyan(val)
    },
    // 点x关闭
    handleClose(done) {
      this.$confirm('确认关闭？')
        .then(_ => {
          done();
        })
        .catch(_ => {});
    },
    // 取消
    cancle(){
      this.listData[this.index].amountRecieved = this.tiaozhengListData[this.index].amountRecieved
      this.dialogVisible = false
    },
    confirm(val){
      this.jiaoyan(val,1)
    },
    // 获取审核状态决定步骤条状态
    getActiveNum(){
      let auditStatus = JSON.parse(window.sessionStorage.getItem('returnConfirmrow')).auditStatus
      if(auditStatus == 0 || auditStatus == 5){
        this.activeNum = 0
      }else if(auditStatus == 1 ){
        this.activeNum = 1
      }else if(auditStatus == 4 ){
        this.activeNum = 2
      }
    },
    // 保存下标
    adjustment(index){
      console.log(index)
      this.dialogVisible = true
      this.index = index
    },
    initPhone(row, column, cellValue, index){
      return util.formatPhoneNumber(cellValue)
    },
    initMoney(row, column, cellValue, index){
      return util.formatMoney(cellValue)
    },
    initTime(row, column, cellValue, index){
      return util.getTimeString(cellValue)
    },
    handleSelectionChange(val) {
      console.log(val);
      this.multipleSelection = val;
    },
    // 编辑
    // handleSizeChange(val) {
    //     console.log(window.sessionStorage.getItem('returnConfirmCheckOrEdit'));
    //   this.pageData.pageSize = val
    //   if(window.sessionStorage.getItem('returnConfirmCheckOrEdit') == 1){
    //     this.getOrderList()
    //   }else if(window.sessionStorage.getItem('returnConfirmCheckOrEdit') == 2){
    //     this.getEditOrderList()
    //   }
    // },
    // 编辑
    // handleCurrentChange(val) {
    //   if(window.sessionStorage.getItem('returnConfirmCheckOrEdit') == 1){
    //     this.getOrderList()
    //   }else if(window.sessionStorage.getItem('returnConfirmCheckOrEdit') == 2){
    //     this.getEditOrderList()
    //   }
    // },
    // 继续添加
    handleSizeChangeNew(val){
      this.pageDataNew.pageSize = val
      this.orderList(this.id)
    },
    // 继续添加
    handleCurrentChangeNew(){
      this.orderList(this.id)
    },
    // 审核通过/拒绝
    handleReject(val){
      this.axios.post(api.passAndReject,{
        reason:this.reason,
        auditStatus:val,
        batchId:JSON.parse(window.sessionStorage.getItem('returnConfirmrow')).id
      }).then(res=>{
        if(res.data.code == 200){
          this.$router.push({path:'/returnConfirm'})
        }
      })
    },

    handleAdd(){
      this.edit = 0
    },
    // 继续添加
    handleSelectionChangeNew(val){
      this.multipleSelectionEditAdd = val
      setTimeout(()=>{
        this.changePageCoreRecordDataAdd()
      },300)
    },
    // 记忆选择核心方法
    changePageCoreRecordDataAdd() {
      // 标识当前行的唯一键的名称
      let idKeyNew = this.idKeyNew;
      let that = this;
      this.multipleSelectionAllAdd = this.multipleSelectionEditAdd;
      // 总选择里面的key集合
      let selectAllIds = [];
      this.multipleSelectionAllAdd.forEach(row => {
        selectAllIds.push(row[idKeyNew]);
      });
      // console.log("总选择的key", selectAllIds);
      this.tempcompanyInfoIdReturnAdd = [];
      // 获取当前页选中的id
      this.multipleSelectionEditAdd.forEach(row => {
        this.tempcompanyInfoIdReturnAdd.push(row[idKeyNew]);
        // 如果总选择里面不包含当前页选中的数据，那么就加入到总选择集合里
        if (selectAllIds.indexOf(row[idKeyNew]) < 0) {
          that.multipleSelectionAllAdd.push(row);
        }
      });
      // console.log("当前也的选中id", this.tempcompanyInfoIdReturnAdd);
      let noSelectIds = [];
      // 得到当前页没有选中的id
      this.listDataNew.forEach(row => {
        if (this.tempcompanyInfoIdReturnAdd.indexOf(row[idKeyNew]) < 0) {
          noSelectIds.push(row[idKeyNew]);
        }
      });
      noSelectIds.forEach(id => {
        if (selectAllIds.indexOf(id) >= 0) {
          for (let i = 0; i < that.multipleSelectionAllAdd.length; i++) {
            if (that.multipleSelectionAllAdd[i][idKeyNew] == id) {
              // 如果总选择中有未被选中的，那么就删除这条
              that.multipleSelectionAllAdd.splice(i, 1);
              break;
            }
          }
        }
      });
    },
    // 查看-订单列表
    getOrderList(){
      this.axios.post(api.getReBatchLookList,{
        batchId:JSON.parse(window.sessionStorage.getItem('returnConfirmrow')).id,
        pageNum:this.pageData.pageNum,
        pageSize:this.pageData.pageSize
      }).then(res=>{
        console.log(res)
        if(res.data.code == 200){
          this.totalSize = res.data.data.total
          this.listData = res.data.data.rows
          this.brokerageTotal = util.formatMoney(res.data.data.brokerageTotal)
          this.returnConfirmList = []
          if(this.listData[0].pictureAddress){
            if(JSON.parse(this.listData[0].pictureAddress).pictures){
              JSON.parse(this.listData[0].pictureAddress).pictures.forEach(item=>{
                this.returnConfirmList.push(item.url)
              })
            }
            if(JSON.parse(this.listData[0].pictureAddress).pdfarr){
              JSON.parse(this.listData[0].pictureAddress).pdfarr.forEach(item=>{
                this.returnConfirmList.push(item.url)
              })
            }
          }
        }
      })
    },

    toggleSelection(rows) {
      console.log(rows);

      if (rows) {
        this.$nextTick(()=>{
          rows.forEach(row => {
            this.$refs.multipleTable.toggleRowSelection(row,true)
          })
        })
      } else {
        this.$refs.multipleTable.clearSelection();
      }
    },
    // 编辑-订单列表
    getEditOrderList(){
      this.axios.post(api.getReConfirmEditList,{
        devId:JSON.parse(window.sessionStorage.getItem('returnConfirmrow')).devId,
        cityId:JSON.parse(window.sessionStorage.getItem('returnConfirmrow')).cityId,
        batchId:JSON.parse(window.sessionStorage.getItem('returnConfirmrow')).id,
        pageNum:this.pageData.pageNum,
        pageSize:this.pageData.pageSize
      }).then(res=>{
        console.log(res);

        if(res.data.code == 200){
          this.totalSize = res.data.data.total
          this.listData = res.data.data.rows
          let companyInfoId = []
          this.listData.forEach((item,index)=>{
            item.index = index
            companyInfoId.push(item.companyInfoId)
          })
          this.id = companyInfoId
          window.localStorage.setItem("tempcompanyInfoIdReturnAdd",companyInfoId)
          console.log(companyInfoId);

          let list = JSON.stringify(this.listData)
          this.tiaozhengListData = JSON.parse(list)
          this.multipleSelection = []
          this.multipleSelection = this.listData
          this.toggleSelection(this.listData)
          this.returnConfirmList = []
          if(res.data.data.pictureAddress){
            if(JSON.parse(res.data.data.pictureAddress).pictures){
              JSON.parse(res.data.data.pictureAddress).pictures.forEach(item=>{
                this.returnConfirmList.push(item.url)
              })
            }
            if(JSON.parse(res.data.data.pictureAddress).pdfarr){
              JSON.parse(res.data.data.pictureAddress).pdfarr.forEach(item=>{
                this.returnConfirmList.push(item.url)
              })
            }
          }
        }
      })
    },
    // 审核记录
    getRemarkList(){
      this.axios.post(api.remarkList,{
        batchId:JSON.parse(window.sessionStorage.getItem('returnConfirmrow')).id
      }).then(res=>{
        if(res.data.code == 200){
          this.recordList = res.data.data
          this.recordList.forEach(item=>{
            item.createTime = util.getTimeString(item.createTime)
          })
        }
      })
    },
    // 保存
    handleSave(val){
      if(this.multipleSelection.length == 0){
        this.$message({
          type:'warning',
          message:'请选择订单'
        })
        return
      }else{
        this.multipleSelection.forEach((item,index)=>{
          item.dataIndex = index + 1
        })
      }
      Promise.all([
          this.$refs.upload1.submit()
        ]).then(res=>{
        if (res[0].length < 1) {
          this.$message({
              message: '回款确认单不能为空',
              type: 'warning'
          });
          return
        }
        // 回款确认单
        this.returnConfirmData.pdfarr = []
        this.returnConfirmData.pictures = []
        res[0].forEach(item=>{
          let suffix = item.substring(item.lastIndexOf('.')+1,item.length)
          if(suffix == 'pdf'){
            this.returnConfirmData.pdfarr.push({
              name:item.substring(item.lastIndexOf('/')+1,item.length),
              url:item
            })
          }else{
            this.returnConfirmData.pictures.push({
              name:item.substring(item.lastIndexOf('/')+1,item.length),
              url:item
            })
          }
        })
        this.axios.post(api.saveReturnConfirm,{
          auditStatus:val,
          batchId:JSON.parse(window.sessionStorage.getItem('returnConfirmrow')).id,
          data:this.multipleSelection,
          pictureAddress:this.returnConfirmData,// 回款确认单
        }).then(res=>{
          console.log(res)
          if(res.data.code == 200){
            this.$router.push({path:"/returnConfirm"})
          }
        })
      })
    }
  },
  computed: {}
}
</script>
<style lang="stylus" scoped>
  .returnConfirmCheck {
    .block{
      margin-top:15px;
    }
    .top{
      margin-bottom :15px;
      font-size :14px;
      color :#909399;
    }
    .one{
      margin-right :50px;
    }
    .pri{
      float :right;
      margin-bottom:15px;
    }
    .part{
      margin-top :30px;
      display:flex;
      font-size :14px;
      color :#909399;
    }
    .txt{
      width :200px;
    }
    .content{
      flex:1;
    }
    .pagination{
      margin-top :20px;
    }
    .content .contentImg{
      width:100%;
    }
    .img{
      display:inline-block;
      width:195px;
      height :150px;
    }
    .img img{
      display:inline-block;
      width:100%;
      height :100%;
    }
    .btn{
      margin-top :40px;
      margin-bottom :40px;
      padding-left :200px;
    }
    .step{
      margin-top :30px;
      margin-left :200px;
      font-size :14px;
      color :#909399;
    }
  }
</style>
